<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Centos7安装Mysql 8.0.33 | KCloud-Platform-Alibaba</title>
    <meta name="generator" content="VuePress 1.9.2">
    <link rel="icon" href="/img/favicon.ico">
    <meta name="description" content="一个基于VuePress的 知识管理&amp;博客 主题">
    <meta name="keywords" content="vuepress,theme,blog,vdoing">
    <meta name="theme-color" content="#11a8cd">
    
    <link rel="preload" href="/assets/css/0.styles.f1160bd0.css" as="style"><link rel="preload" href="/assets/js/app.c1130a26.js" as="script"><link rel="preload" href="/assets/js/2.4ec61f8d.js" as="script"><link rel="preload" href="/assets/js/6.d5489e3f.js" as="script"><link rel="prefetch" href="/assets/js/10.e3efb9c9.js"><link rel="prefetch" href="/assets/js/11.215e8173.js"><link rel="prefetch" href="/assets/js/12.e49aaa47.js"><link rel="prefetch" href="/assets/js/13.c0cadd0c.js"><link rel="prefetch" href="/assets/js/14.354c04aa.js"><link rel="prefetch" href="/assets/js/15.0ccb9393.js"><link rel="prefetch" href="/assets/js/16.284febc7.js"><link rel="prefetch" href="/assets/js/17.f10e7f0d.js"><link rel="prefetch" href="/assets/js/18.3e728c4a.js"><link rel="prefetch" href="/assets/js/19.5a760622.js"><link rel="prefetch" href="/assets/js/3.cd68975a.js"><link rel="prefetch" href="/assets/js/4.1e281399.js"><link rel="prefetch" href="/assets/js/5.fa0f019a.js"><link rel="prefetch" href="/assets/js/7.c3b0abd7.js"><link rel="prefetch" href="/assets/js/8.1acb47f0.js"><link rel="prefetch" href="/assets/js/9.e9e30dab.js">
    <link rel="stylesheet" href="/assets/css/0.styles.f1160bd0.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/img/logo.png" alt="KCloud-Platform-Alibaba" class="logo"> <span class="site-name can-hide">KCloud-Platform-Alibaba</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="指南" class="dropdown-title"><a href="/pages/a2f161/" aria-current="page" class="link-title router-link-exact-active router-link-active">指南</a> <span class="title" style="display:none;">指南</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>环境搭建</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/pages/a2f161/" aria-current="page" class="nav-link router-link-exact-active router-link-active">Centos7安装Mysql 8.0.33</a></li><li class="dropdown-subitem"><a href="/pages/90401a/" class="nav-link">Centos7安装Redis 7.0.11</a></li><li class="dropdown-subitem"><a href="/pages/0fb88c/" class="nav-link">Centos7安装RocketMQ 5.1.1</a></li><li class="dropdown-subitem"><a href="/pages/65acfd/" class="nav-link">Centos7安装Jdk 17.0.7</a></li><li class="dropdown-subitem"><a href="/pages/65acff/" class="nav-link">Centos7安装Docker 23.0.6</a></li><li class="dropdown-subitem"><a href="/pages/552b64/" class="nav-link">Docker安装RabbitMQ 3.12.2</a></li><li class="dropdown-subitem"><a href="/pages/d715cf/" class="nav-link">Centos7安装Elasticsearch 8.6.2</a></li></ul></li><li class="dropdown-item"><h4>快速上手</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/pages/10bfa2/" class="nav-link">一键部署</a></li><li class="dropdown-subitem"><a href="/pages/10bfa7/" class="nav-link">项目启动</a></li><li class="dropdown-subitem"><a href="/pages/192acb/" class="nav-link">API网关</a></li><li class="dropdown-subitem"><a href="/pages/36da89/" class="nav-link">认证授权</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">服务注册&amp;发现</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">配置中心</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">分布式事务</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">多级缓存</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">数据推送</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">消息队列</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">服务熔断&amp;降级</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">远程调用</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">链路跟踪</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">对象存储</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">日志分析</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">分布式锁</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">服务监控</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">读写分离&amp;分库分表</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">多数据源</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">数据库版本控制</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">持续集成&amp;交付</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">自动化部署</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">接口幂等性</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">接口安全</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">XSS攻击</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">统计报表</a></li><li class="dropdown-subitem"><a href="/pages/10bfa8/" class="nav-link">SSL证书</a></li></ul></li><li class="dropdown-item"><h4>系统设计</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/" class="nav-link">高可用设计</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">多租户设计</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">权限设计</a></li></ul></li><li class="dropdown-item"><h4>工具使用</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/" class="nav-link">Git使用</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">Maven使用</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">Docker使用</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">Jenkins使用</a></li></ul></li><li class="dropdown-item"><h4>第三方对接</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/" class="nav-link">微信公众号对接</a></li></ul></li><li class="dropdown-item"><h4>脚本使用</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/" class="nav-link">Linux shell脚本使用</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">Lua脚本使用</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">Window bat脚本使用</a></li></ul></li><li class="dropdown-item"><h4>技术分享</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/" class="nav-link">RocketMQ的冒险之旅（先占占位置）</a></li></ul></li><li class="dropdown-item"><h4>架构演进</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/" class="nav-link">老寇云平台架构演进（先占占位置）</a></li></ul></li></ul></div></div><div class="nav-item"><a href="/pages/1b12ed/" class="nav-link">赞助</a></div> <a href="https://github.com/KouShenhai/KCloud-Platform-Alibaba" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><!----> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="指南" class="dropdown-title"><a href="/pages/a2f161/" aria-current="page" class="link-title router-link-exact-active router-link-active">指南</a> <span class="title" style="display:none;">指南</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>环境搭建</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/pages/a2f161/" aria-current="page" class="nav-link router-link-exact-active router-link-active">Centos7安装Mysql 8.0.33</a></li><li class="dropdown-subitem"><a href="/pages/90401a/" class="nav-link">Centos7安装Redis 7.0.11</a></li><li class="dropdown-subitem"><a href="/pages/0fb88c/" class="nav-link">Centos7安装RocketMQ 5.1.1</a></li><li class="dropdown-subitem"><a href="/pages/65acfd/" class="nav-link">Centos7安装Jdk 17.0.7</a></li><li class="dropdown-subitem"><a href="/pages/65acff/" class="nav-link">Centos7安装Docker 23.0.6</a></li><li class="dropdown-subitem"><a href="/pages/552b64/" class="nav-link">Docker安装RabbitMQ 3.12.2</a></li><li class="dropdown-subitem"><a href="/pages/d715cf/" class="nav-link">Centos7安装Elasticsearch 8.6.2</a></li></ul></li><li class="dropdown-item"><h4>快速上手</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/pages/10bfa2/" class="nav-link">一键部署</a></li><li class="dropdown-subitem"><a href="/pages/10bfa7/" class="nav-link">项目启动</a></li><li class="dropdown-subitem"><a href="/pages/192acb/" class="nav-link">API网关</a></li><li class="dropdown-subitem"><a href="/pages/36da89/" class="nav-link">认证授权</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">服务注册&amp;发现</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">配置中心</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">分布式事务</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">多级缓存</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">数据推送</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">消息队列</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">服务熔断&amp;降级</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">远程调用</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">链路跟踪</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">对象存储</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">日志分析</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">分布式锁</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">服务监控</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">读写分离&amp;分库分表</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">多数据源</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">数据库版本控制</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">持续集成&amp;交付</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">自动化部署</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">接口幂等性</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">接口安全</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">XSS攻击</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">统计报表</a></li><li class="dropdown-subitem"><a href="/pages/10bfa8/" class="nav-link">SSL证书</a></li></ul></li><li class="dropdown-item"><h4>系统设计</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/" class="nav-link">高可用设计</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">多租户设计</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">权限设计</a></li></ul></li><li class="dropdown-item"><h4>工具使用</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/" class="nav-link">Git使用</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">Maven使用</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">Docker使用</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">Jenkins使用</a></li></ul></li><li class="dropdown-item"><h4>第三方对接</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/" class="nav-link">微信公众号对接</a></li></ul></li><li class="dropdown-item"><h4>脚本使用</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/" class="nav-link">Linux shell脚本使用</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">Lua脚本使用</a></li><li class="dropdown-subitem"><a href="/" class="nav-link">Window bat脚本使用</a></li></ul></li><li class="dropdown-item"><h4>技术分享</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/" class="nav-link">RocketMQ的冒险之旅（先占占位置）</a></li></ul></li><li class="dropdown-item"><h4>架构演进</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/" class="nav-link">老寇云平台架构演进（先占占位置）</a></li></ul></li></ul></div></div><div class="nav-item"><a href="/pages/1b12ed/" class="nav-link">赞助</a></div> <a href="https://github.com/KouShenhai/KCloud-Platform-Alibaba" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>环境搭建</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/a2f161/" aria-current="page" class="active sidebar-link">Centos7安装Mysql 8.0.33</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level2"><a href="/pages/a2f161/#下载mysql" class="sidebar-link">下载Mysql</a></li><li class="sidebar-sub-header level2"><a href="/pages/a2f161/#安装准备" class="sidebar-link">安装准备</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level4"><a href="/pages/a2f161/#卸载mariadb" class="sidebar-link">卸载MariaDB</a></li><li class="sidebar-sub-header level4"><a href="/pages/a2f161/#检查依赖" class="sidebar-link">检查依赖</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/pages/a2f161/#开始安装" class="sidebar-link">开始安装</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level6"><a href="/pages/a2f161/#上传压缩包-略" class="sidebar-link">上传压缩包（略）</a></li><li class="sidebar-sub-header level6"><a href="/pages/a2f161/#解压" class="sidebar-link">解压</a></li><li class="sidebar-sub-header level6"><a href="/pages/a2f161/#重命名" class="sidebar-link">重命名</a></li><li class="sidebar-sub-header level6"><a href="/pages/a2f161/#创建存储数据文件" class="sidebar-link">创建存储数据文件</a></li><li class="sidebar-sub-header level6"><a href="/pages/a2f161/#创建用户组并赋值" class="sidebar-link">创建用户组并赋值</a></li><li class="sidebar-sub-header level6"><a href="/pages/a2f161/#初始化mysql" class="sidebar-link">初始化Mysql</a></li><li class="sidebar-sub-header level6"><a href="/pages/a2f161/#配置参数" class="sidebar-link">配置参数</a></li><li class="sidebar-sub-header level6"><a href="/pages/a2f161/#启动mysql" class="sidebar-link">启动Mysql</a></li><li class="sidebar-sub-header level6"><a href="/pages/a2f161/#设置密码" class="sidebar-link">设置密码</a></li><li class="sidebar-sub-header level6"><a href="/pages/a2f161/#开放远程访问" class="sidebar-link">开放远程访问</a></li><li class="sidebar-sub-header level6"><a href="/pages/a2f161/#关闭防火墙" class="sidebar-link">关闭防火墙</a></li><li class="sidebar-sub-header level6"><a href="/pages/a2f161/#安装完毕" class="sidebar-link">安装完毕！！！</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/pages/a2f161/#参考资料" class="sidebar-link">参考资料</a></li></ul></li><li><a href="/pages/90401a/" class="sidebar-link">Centos7安装Redis 7.0.11</a></li><li><a href="/pages/0fb88c/" class="sidebar-link">Centos7安装RocketMQ 5.1.1</a></li><li><a href="/pages/65acfd/" class="sidebar-link">Centos7安装Jdk 17.0.7</a></li><li><a href="/pages/65acff/" class="sidebar-link">Centos7安装Docker 23.0.6</a></li><li><a href="/pages/552b64/" class="sidebar-link">Docker安装RabbitMQ 3.12.2</a></li><li><a href="/pages/d715cf/" class="sidebar-link">Centos7安装Elasticsearch 8.6.2</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>快速上手</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/10bfa2/" class="sidebar-link">一键部署</a></li><li><a href="/pages/10bfa7/" class="sidebar-link">项目启动</a></li><li><a href="/pages/192acb/" class="sidebar-link">API网关</a></li><li><a href="/pages/36da89/" class="sidebar-link">认证授权</a></li><li><a href="/pages/10bfa8/" class="sidebar-link">SSL证书</a></li></ul></section></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-06225672><div class="articleInfo" data-v-06225672><ul class="breadcrumbs" data-v-06225672><li data-v-06225672><a href="/" title="首页" class="iconfont icon-home router-link-active" data-v-06225672></a></li> <li data-v-06225672><span data-v-06225672>指南</span></li><li data-v-06225672><span data-v-06225672>环境搭建</span></li></ul> <div class="info" data-v-06225672><div title="作者" class="author iconfont icon-touxiang" data-v-06225672><a href="https://github.com/KouShenhai" target="_blank" title="作者" class="beLink" data-v-06225672>KCloud-Platform-Alibaba</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-06225672><a href="javascript:;" data-v-06225672>2023-09-26</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">Centos7安装Mysql 8.0.33<!----></h1>  <div class="theme-vdoing-content content__default"><p>你好呀，我的老朋友！我是老寇，欢迎来到老寇云平台！<br>
话不多说，跟我一起安装Mysql。</p> <h2 id="下载mysql"><a href="#下载mysql" class="header-anchor">#</a> 下载Mysql</h2> <p><a target="_blank" href="https://dev.mysql.com/downloads/mysql">Mysql官网下载地址</a><br> <img src="/img/1/img.png"></p> <h2 id="安装准备"><a href="#安装准备" class="header-anchor">#</a> 安装准备</h2> <p>注：Mysql会与MariaDB文件冲突，需要先卸载掉MariaDB</p> <h4 id="卸载mariadb"><a href="#卸载mariadb" class="header-anchor">#</a> 卸载MariaDB</h4> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 检查是否安装MariaDB</span>
<span class="token function">rpm</span> -qa<span class="token operator">|</span><span class="token function">grep</span> mariadb
</code></pre></div><img src="/img/1/img_1.png"> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 卸载 </span>
<span class="token comment"># rpm -e --nodeps 文件名</span>
<span class="token function">rpm</span> <span class="token parameter variable">-e</span> <span class="token parameter variable">--nodeps</span> mariadb-libs-5.5.35-3.el7.x86_64
</code></pre></div><img src="/img/1/img_2.png"> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 检查是否卸载干净</span>
<span class="token function">rpm</span> -qa<span class="token operator">|</span><span class="token function">grep</span> mariadb
</code></pre></div><img src="/img/1/img_3.png"> <h4 id="检查依赖"><a href="#检查依赖" class="header-anchor">#</a> 检查依赖</h4> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 是否安装libaio</span>
<span class="token function">rpm</span> -qa<span class="token operator">|</span><span class="token function">grep</span> libaio
</code></pre></div><img src="/img/1/img_4.png"> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 没有libaio则安装</span>
yum <span class="token parameter variable">-y</span> <span class="token function">install</span> libaio
</code></pre></div><img src="/img/1/img_5.png"> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 查看安装numactl</span>
<span class="token function">rpm</span> -qa<span class="token operator">|</span><span class="token function">grep</span> numactl
</code></pre></div><img src="/img/1/img_6.png"> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 没有则安装numactl</span>
yum <span class="token parameter variable">-y</span> <span class="token function">install</span> numactl
</code></pre></div><img src="/img/1/img_7.png"> <h2 id="开始安装"><a href="#开始安装" class="header-anchor">#</a> 开始安装</h2> <h6 id="上传压缩包-略"><a href="#上传压缩包-略" class="header-anchor">#</a> 上传压缩包（略）</h6> <h6 id="解压"><a href="#解压" class="header-anchor">#</a> 解压</h6> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 拆分 =&gt; tar -xvf 包名</span>
<span class="token function">tar</span> <span class="token parameter variable">-xvf</span> mysql-8.0.33-el7-x86_64.tar
<span class="token comment"># 解压 =&gt; tar -zxvf 包名</span>
<span class="token function">tar</span> <span class="token parameter variable">-zxvf</span> mysql-8.0.33-el7-x86_64.tar.gz
</code></pre></div><img src="/img/1/img_8.png"> <img src="/img/1/img_9.png"> <h6 id="重命名"><a href="#重命名" class="header-anchor">#</a> 重命名</h6> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">mv</span> mysql-8.0.33-el7-x86_64 /usr/local/mysql8
</code></pre></div><img src="/img/1/img_10.png"> <h6 id="创建存储数据文件"><a href="#创建存储数据文件" class="header-anchor">#</a> 创建存储数据文件</h6> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">mkdir</span> <span class="token parameter variable">-p</span> /usr/local/mysql8/data
</code></pre></div><img src="/img/1/img_11.png"> <h6 id="创建用户组并赋值"><a href="#创建用户组并赋值" class="header-anchor">#</a> 创建用户组并赋值</h6> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 创建用户组</span>
<span class="token function">groupadd</span> mysql
<span class="token comment"># 创建用户</span>
<span class="token comment"># -r：创建系统用户</span>
<span class="token comment"># -g：指定用户组</span>
<span class="token function">useradd</span> <span class="token parameter variable">-r</span> <span class="token parameter variable">-g</span> mysql mysql
<span class="token comment"># 修改范围和权限</span>
<span class="token function">chown</span> <span class="token parameter variable">-R</span> mysql:mysql /usr/local/mysql8
<span class="token function">chmod</span> <span class="token parameter variable">-R</span> <span class="token number">755</span> /usr/local/mysql8
</code></pre></div><img src="/img/1/img_12.png"> <img src="/img/1/img_13.png"> <img src="/img/1/img_14.png"> <h6 id="初始化mysql"><a href="#初始化mysql" class="header-anchor">#</a> 初始化Mysql</h6> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token builtin class-name">cd</span> /usr/local/mysql8/bin
<span class="token comment"># 初始化完成后会打印随机密码</span>
./mysqld <span class="token parameter variable">--initialize</span> <span class="token parameter variable">--user</span><span class="token operator">=</span>mysql <span class="token parameter variable">--datadir</span><span class="token operator">=</span>/usr/local/mysql8/data <span class="token parameter variable">--basedir</span><span class="token operator">=</span>/usr/local/mysql8
</code></pre></div><img src="/img/1/img_15.png"> <img src="/img/1/img_16.png"> <h6 id="配置参数"><a href="#配置参数" class="header-anchor">#</a> 配置参数</h6> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 创建文件</span>
<span class="token function">touch</span> /usr/local/mysql8/my.cnf

<span class="token comment"># 复制以下内容，根据需要修改</span>
<span class="token punctuation">[</span>client<span class="token punctuation">]</span>
port <span class="token operator">=</span> <span class="token number">3306</span>
socket <span class="token operator">=</span> /usr/local/mysql8/data/mysql.sock
default-character-set <span class="token operator">=</span> utf8mb4

<span class="token punctuation">[</span>mysql<span class="token punctuation">]</span>  
default-character-set <span class="token operator">=</span> utf8mb4

<span class="token punctuation">[</span>mysqld<span class="token punctuation">]</span>  
character-set-client-handshake <span class="token operator">=</span> FALSE
character-set-server <span class="token operator">=</span> utf8mb4
collation-server <span class="token operator">=</span> utf8mb4_general_ci
init_connect <span class="token operator">=</span> <span class="token string">'SET NAMES utf8mb4'</span>

port <span class="token operator">=</span> <span class="token number">3306</span>
socket <span class="token operator">=</span> /usr/local/mysql8/data/mysql.sock
skip-external-locking
key_buffer_size <span class="token operator">=</span> 16M
max_allowed_packet <span class="token operator">=</span> 1M
table_open_cache <span class="token operator">=</span> <span class="token number">64</span>
sort_buffer_size <span class="token operator">=</span> 512K
net_buffer_length <span class="token operator">=</span> 8K
read_buffer_size <span class="token operator">=</span> 256K
read_rnd_buffer_size <span class="token operator">=</span> 512K
myisam_sort_buffer_size <span class="token operator">=</span> 8M
datadir <span class="token operator">=</span> /usr/local/mysql8/data
lower_case_table_names <span class="token operator">=</span> <span class="token number">1</span>
innodb_flush_log_at_trx_commit <span class="token operator">=</span> <span class="token number">1</span>
sync_binlog <span class="token operator">=</span> <span class="token number">1</span>
<span class="token comment">#lower_case_table_names=1</span>
<span class="token comment">#如果要设置lower_case_table_names可以在初始化里面设置 ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql --lower_case_table_names=1</span>

<span class="token punctuation">[</span>mysqldump<span class="token punctuation">]</span>
quick
max_allowed_packet <span class="token operator">=</span> 16M

<span class="token punctuation">[</span>mysql<span class="token punctuation">]</span>
no-auto-rehash

<span class="token punctuation">[</span>myisamchk<span class="token punctuation">]</span>
key_buffer_size <span class="token operator">=</span> 20M
sort_buffer_size <span class="token operator">=</span> 20M
read_buffer <span class="token operator">=</span> 2M
write_buffer <span class="token operator">=</span> 2M

<span class="token punctuation">[</span>mysqlhotcopy<span class="token punctuation">]</span>
interactive-timeout
</code></pre></div><img src="/img/1/img_17.png"> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 修改权限</span>
<span class="token function">chmod</span> <span class="token number">777</span> /usr/local/mysql8/my.cnf
</code></pre></div><img src="/img/1/img_18.png"> <h6 id="启动mysql"><a href="#启动mysql" class="header-anchor">#</a> 启动Mysql</h6> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 启动</span>
./mysqld_safe /usr/local/mysql8/my.cnf <span class="token operator">&amp;</span>
<span class="token comment"># 查看进程</span>
<span class="token function">netstat</span> <span class="token parameter variable">-ntlp</span>
</code></pre></div><img src="/img/1/img_19.png"> <img src="/img/1/img_20.png"> <h6 id="设置密码"><a href="#设置密码" class="header-anchor">#</a> 设置密码</h6> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 登录 =&gt; 密码就是截图的随机密码</span>
./mysql <span class="token parameter variable">-uroot</span> <span class="token parameter variable">-p</span>
<span class="token comment"># 修改密码</span>
ALTER <span class="token environment constant">USER</span> <span class="token string">'root'</span>@<span class="token string">'localhost'</span> IDENTIFIED WITH mysql_native_password BY <span class="token string">'laokou123'</span><span class="token punctuation">;</span>
</code></pre></div><img src="/img/1/img_21.png"> <h6 id="开放远程访问"><a href="#开放远程访问" class="header-anchor">#</a> 开放远程访问</h6> <div class="language-shell extra-class"><pre class="language-shell"><code>use mysql<span class="token punctuation">;</span>
update user <span class="token builtin class-name">set</span> <span class="token assign-left variable">user.Host</span><span class="token operator">=</span><span class="token string">'%'</span> where <span class="token assign-left variable">user.User</span><span class="token operator">=</span><span class="token string">'root'</span><span class="token punctuation">;</span>
<span class="token comment"># 刷新权限</span>
flush privileges<span class="token punctuation">;</span>
</code></pre></div><img src="/img/1/img_22.png"> <h6 id="关闭防火墙"><a href="#关闭防火墙" class="header-anchor">#</a> 关闭防火墙</h6> <div class="language-shell extra-class"><pre class="language-shell"><code>systemctl stop firewalld.service
</code></pre></div><img src="/img/1/img_23.png"> <h6 id="安装完毕"><a href="#安装完毕" class="header-anchor">#</a> 安装完毕！！！</h6> <p>我是老寇，我们下次再见啦！</p> <h2 id="参考资料"><a href="#参考资料" class="header-anchor">#</a> 参考资料</h2> <p><a href="https://blog.csdn.net/qq_36408717/article/details/126705287" target="_blank" rel="noopener noreferrer">CentOS7安装MySQL8(亲测无坑百分百安装成功)<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></div></div>  <div class="page-edit"><!----> <!----> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2023/09/26, 11:24:31</span></div></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><!----> <a href="/pages/90401a/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">Centos7安装Redis 7.0.11</div></a></div> <div class="page-nav"><p class="inner"><!----> <span class="next"><a href="/pages/90401a/">Centos7安装Redis 7.0.11</a>→
      </span></p></div></div></div> <!----></main></div> <div class="footer"><div class="icons"><a href="mailto:2413176044@qq.com" title="发邮件" target="_blank" class="iconfont icon-youjian"></a><a href="https://github.com/KouShenhai" title="GitHub" target="_blank" class="iconfont icon-github"></a></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2022-2023
    <span>laokou | Apache 2.0 License</span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"></div></div>
    <script src="/assets/js/app.c1130a26.js" defer></script><script src="/assets/js/2.4ec61f8d.js" defer></script><script src="/assets/js/6.d5489e3f.js" defer></script>
  </body>
</html>
